package test;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

import hyl.core.io.MyPath;
import hyl.core.reflect.MyRef2;

public class testloadjar {
	public static void main(String[] args)
            throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
            SecurityException, ClassNotFoundException, InstantiationException, IOException {
//         String path =
//         "/xx/.m2/repository/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar";
       // String path = "commons-lang3-3.8.jar";//jar文件需放在工程目录下
//MyPath.getSystemResource().getPath()+
       // loadJar(path);
      //  Class<?> aClass = Class.forName("org.apache.commons.lang3.StringUtils");
        String path="D:\\work\\java\\hyl.test\\lib\\commons-lang3-3.8.jar";
 
        //System.out.println(path); 
        Class<?> aClass =  MyRef2.  getJarClass(path,"org.apache.commons.lang3.StringUtils");
      //  Class<?> aClass =   (new MyRef2()).  loadClassFromJar(path,"org.apache.commons.lang3.StringUtils");
        
        Object instance = aClass.newInstance();
        Object strip = aClass.getDeclaredMethod("strip", String.class, String.class).invoke(instance,
                "[1,2,3,4,5,6,2,3,5,1]", "[]");
        System.out.println(strip);

    }

  
}
